<template>
    <div>
        <van-nav-bar id="reset" title="我的患者" left-arrow @click-left="backHandle" fixed z-index="100" />

        <div class="pageCon fuPage">

            <div class="listBox">
                <!-- <div class="listTop">
                    <span>
                        我的患者
                    </span>
                    <div>
                        <span>筛选</span>
                        <van-popover v-model="showPopover" trigger="click" :actions="actions" @select="onSelect">
                            <template #reference>
                                {{ type == -1 ? '全部' : type == 1 ? '已使用' : '未使用' }}<van-icon name="bars" />
                            </template>
                        </van-popover>
                    </div>
                </div> -->
                <div class="listMain">
                    <template v-if="patientList.length != 0">
                        <div class="itemBox" v-for="(item, index) in patientList" :key="index">
                            <div class="line1">
                                <span>{{ item.userName }} <span>{{ item.userTel }}</span> <span>{{ item.userSex
                                        }}</span>
                                </span>
                                <span>
                                    <span @click="toPage('/healthRecords', item)">档案报告</span>
                                    <span @click="toPage('/patientDetail', item)">详情</span>
                                </span>
                            </div>
                            <div>
                                <!-- <span>注册时间：2024-05-21 16:18</span> -->
                                <span v-if="item.isVip != 0">会员：{{ item.vipTime }} 到期</span>
                            </div>
                        </div>
                    </template>
                    <div class="emptyBox" v-else>
                        <img src="../../assets/tip_content.png">
                    </div>
                </div>
            </div>

        </div>



    </div>

</template>

<script>

import { listUsersByDoctor } from '../../network/aide'
export default {
    name: 'HomeR',
    data() {
        return {
            isLoading: false,
            hisFlag: 0, //  1  亲情就诊  0 加号记录

            type: 0,// -1全部  1 已使用 0 未使用
            patientList: [],
            showPopover: false,
            actions: [
                {
                    text: '全部',
                    value: -1
                },
                {
                    text: '未使用',
                    value: 0
                },
                {
                    text: '已使用',
                    value: 1
                }
            ],

        }
    },
    mounted() {

    },
    methods: {

        onSelect() {


        },
        toPage(url, obj) {
            this.$router.push({
                path: url,
                query: {
                    userId: obj.userId || 4,
                },
            });
        },
        backHandle() {
            this.$router.back()
        },

        getPatientList() {
            listUsersByDoctor(
                {
                    userId: localStorage.userId,
                    userType: localStorage.userType,
                    userName: ''
                }
            ).then(res => {
                if (res.flag) {
                    this.isLoading = false
                    this.patientList = res.data
                    console.log(this.patientList);
                }
            })
        },

        pullHandle() {

            this.isLoading = true
            this.getPatientList()

        },

    },
    created() {
        this.getPatientList()
        console.log(this.$router);
        console.log(this.$router.history.current.query);
        this.hisFlag = this.$router.history.current.query.flag
    },
    //计算属性
    computed: {

    },
    filters: {

    },
    watch: {
    }

}

</script>

<style lang='less' scoped>
.listMain {
    height: 100%;

}

.pageCon {

    padding: 112px 20px 0 !important;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: #EEF1F7;
    overflow-y: scroll;
}


.listBox {
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0px 2px 6px 0px rgba(51, 51, 51, 0.08);
    overflow-y: scroll;
}


.listTop {
    position: sticky;
    top: 0px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 30px 34px 10px 44px;
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: 500;
    font-size: 28px;
    color: #333333;
    background: #fff;
}

.listTop>div>span:nth-child(2) {
    margin-left: 30px;
    color: #999999;
}

.itemBox {
    box-sizing: border-box;
    padding: 44px 30px 44px 44px;
    width: 100%;
    border-bottom: 2px solid #f2f2f2;
}

.itemBox>div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 28px;
    color: #333333;
    line-height: 38px;

}

.itemBox>div:nth-child(2) {
    margin-top: 12px;
}

.itemBox>div:nth-child(2)>span {
    font-size: 24px;
    color: #999999;
}

.line1>span>span {
    font-size: 24px;
    color: #999999;
}

.line1>span:nth-child(2)>span {
    color: #1BA45E;
}

.line1>span:nth-child(2)>span:nth-child(2)::before {
    margin: 0 12px 0 14px;
    display: inline-block;
    content: '';
    width: 3px;
    height: 14px;
    background: #1BA45E;
    border-radius: 2px;
}

#reset /deep/ .van-nav-bar__left .van-nav-bar__text,
#reset /deep/ .van-nav-bar__left .van-icon {
    color: #333 !important;
}

.emptyBox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.emptyBox>img {
    margin-top: 400px;
    width: 374px;
    height: 314px;
}
</style>